///////////////////////////////////////////////////////////
//  InsertItemCommand.cpp
//  Implementation of the Class InsertItemCommand
//  Created on:      21-Sep-2013 12:10:03 PM
//  Original author: Jakkaphan Aiemcharoenjit
///////////////////////////////////////////////////////////

#include "InsertItemCommand.h"
#include "CurrentCommand.h"

using namespace UI;
using namespace UI::CMD;

InsertItemCommand::InsertItemCommand(CCreateItemView* createItem, CCreateTemplateView* createTemplate)
{
  this->m_type = ICommand::INSERTITEM_CMD;
  this->m_createTemplateView = createTemplate;
  this->m_createItemView = createItem;
}


InsertItemCommand::~InsertItemCommand()
{

}

void InsertItemCommand::Execute()
{
  IObject* data = this->m_createTemplateView->GetCurrentData();
  if(data)
  {
    switch(data->GetType())
    {
    case IObject::ITEM_T:
      {
        this->m_createItemView->SetCurListBox(1);
      }
      break;
    case IObject::HEARDER_T:
      {
        this->m_createItemView->SetCurListBox(0);
      }
      break;
    default: break;
    }
  }
  else
  {
    this->m_createItemView->SetCurListBox(0);
  }
  this->m_createItemView->SetTitleView("Insert item");
  this->m_createItemView->ItemTypeEnable(true);
  // Set current command
  CurrentCommand::GetInstance()->SetCurrentCommand(this->m_type);
}


ICommand::CommandType InsertItemCommand::GetType()
{
	return this->m_type;
}